package com.aitaoxue.palx.ui;

import android.view.View;
import android.widget.TextView;
import butterknife.InjectView;

import com.aitaoxue.palx.R;
import com.aitaoxue.palx.api.ApiHttpClient;
import com.aitaoxue.palx.base.BaseActivity;
import com.aitaoxue.palx.bean.Course;
import com.aitaoxue.palx.widget.CircleImageView;
import com.nostra13.universalimageloader.core.ImageLoader;

public class CourseDetailActivity extends BaseActivity {

	@InjectView(R.id.time)
	TextView time;
	@InjectView(R.id.number)
	TextView number;
	@InjectView(R.id.finish)
	TextView finish;
	@InjectView(R.id.course_name)
	TextView name;
	@InjectView(R.id.course_num)
	TextView num;
	@InjectView(R.id.course_price)
	TextView price;
	@InjectView(R.id.all_price)
	TextView allPrice;
	@InjectView(R.id.header)
	CircleImageView header;
	@InjectView(R.id.parent_name)
	TextView parentName;
	@InjectView(R.id.parent_phone)
	TextView parentPhone;
	@InjectView(R.id.parnet_address)
	TextView parentAddress;

	@Override
	protected boolean hasBackButton() {
		return true;
	}

	@Override
	protected int getActionBarTitle() {
		return R.string.course_detail;
	}

	@Override
	protected int getLayoutId() {
		return R.layout.activity_course_detail;
	}

	@Override
	public void onClick(View v) {

	}

	@Override
	public void initView() {
		Course course = (Course) getIntent().getSerializableExtra("course");
		String type = getIntent().getStringExtra("type");

		time.setText("下单时间: " + course.getOrder_date());
		number.setText("订单编号: " + course.getOrder_id());

		switch (type) {
		case Course.NOT_DEAL:
		case Course.DEALING:
			finish.setText("已完成: " + course.getOrder_finished() + "/"
					+ course.getOrder_num());
			break;
		case Course.DEALED:
			finish.setText("已完结");
			break;
		default:
			break;
		}

		name.setText("课程名称: " + course.getGood_kind_name());
		num.setText("课程数量: " + course.getOrder_num());
		price.setText("订课价格: ￥" + course.getOrder_price() + "元/小时");
		allPrice.setText("总价: ￥"
				+ String.valueOf(Float.parseFloat(course.getOrder_price())
						* Integer.parseInt(course.getOrder_num())) + "元");

		parentName.setText("家长昵称: " + course.getUser_name());
		parentPhone.setText("手机号: " + course.getUser_phone());
		parentAddress.setText("地址: " + course.getUser_addr_address());

		ImageLoader.getInstance().displayImage(
				ApiHttpClient.HEADER_PREFIX + course.getUser_head_thumb(),
				header);

	}

	@Override
	public void initData() {
		// TODO Auto-generated method stub

	}

}
